import { exercises } from "@/js/exercises";
import axios from "axios";
import {
    ElMessage,
} from "element-plus";

const baseURL = '/api/usercard';  // 前端可访问的完整后端路径
const instance = axios.create({
    baseURL,
    timeout: 30000,
});
export async function getAllUserCard() {
    try {
        const result = await instance.get("/getAll");
        return result.data;

    } catch (err) {
        console.error("Error fetching users:", err);
    }
}

export async function getName(id) {
    try {
        const result = await instance.get(`/getname/${id}`);
        return result.data;

    } catch (err) {
        console.error("Error fetching users:", err);
    }
}

export async function update(usercard) {
    try {
        const result = await instance.put(`/update/${usercard.cardId}`, usercard, {
            headers: {
                'Content-Type': 'application/json',
            },
        })
        return result.data;
    } catch (err) {
        console.error("Error fetching users:", err);
    }

}